package bookez.model.businessobject;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@NamedQueries({
		
	@NamedQuery(
		name	= "TripDailyRecord.findAll",
		query	= "from TripDailyRecord"
	),//end query findAll
	
})//end NamedQueries


@Entity
@Table ( name ="trip_instance" )
public class TripDailyRecord extends BusinessObject implements Serializable {
	
	public static class NamedQueries {
		public static final String FIND_ALL	 = "TripDailyRecord.findAll";
	}//end NamedQueries
	
	@Id
	@GeneratedValue
	public Long getId() { return this.id; }
	public void setId( Long value ) { this.id = value; }
	
	@Column ( name="departure_date" )
	public Date getDepartureDate() { return this.departureDate; }
	public void setDepartureDate( Date value ) { this.departureDate = value; }
	
	@Column ( name="is_disabled" )
	public boolean isDisabled() { return this.isDisabled; }
	public void    setDisabled( boolean value ) { this.isDisabled = value; }
		
	@ManyToOne ( cascade=CascadeType.ALL, fetch=FetchType.LAZY)
	@JoinColumn ( name="trip_id", nullable=false)
	public TripSchedule getSchedule() { return this.schedule; }
	public void setSchedule( TripSchedule value ) { this.schedule = value; }
	
	@Override
	protected boolean blindlyEquals(Object obj) {
		// TODO Auto-generated method stub
		if( !( obj instanceof TripDailyRecord ) ) { return false; }
		final TripDailyRecord other = (TripDailyRecord) obj;
		
		boolean idChecked = checkProperty( this.getId(), other.getId() );
		boolean timeChecked = checkProperty( this.getDepartureDate(), other.getDepartureDate() );
		boolean scheduleChecked = checkProperty( this.getSchedule(), other.getSchedule() );
		
		return processResult( new boolean[] { idChecked, timeChecked, scheduleChecked });
	}//end method blindlyEquals
	
	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		addPropertyToHashCode( getSchedule() );
		return toHashCode();
	}//method hashCode
	
	private Long id;
	private Date departureDate;
	private TripSchedule schedule;
	private boolean isDisabled;
	
	private static final long serialVersionUID = 8289068682516371011L;
	
}//end class Trip
